home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / ubiquity / console-setup / console-setup.postinst next >
Encoding:
Text File  |  2009-04-19  |  4.2 KB  |  168 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. # Source debconf library.
  6. . /usr/share/debconf/confmodule
  7.  
  8. # The same as /usr/bin/which - in order to make this script work
  9. # in environments where "which" is not available
  10. which () {
  11.     local IFS
  12.     IFS=:
  13.     for i in $PATH; do
  14.     if [ -x "$i/$1" ]; then
  15.         echo "$i/$1"
  16.         return 0
  17.     fi
  18.     done
  19.     return 1
  20. }
  21.  
  22. # In order to make this script work in environments where
  23. # "md5sum" is not available
  24. md5sum=`which md5sum`
  25. if [ -z "$md5sum" ]; then
  26.     md5sum=true
  27. fi
  28.  
  29. # In d-i the config script is not executed automatically
  30. if [ -f /var/lib/dpkg/info/console-setup.config ]; then
  31.     . /var/lib/dpkg/info/console-setup.config
  32. fi
  33.  
  34. db_fset console-setup/dont_ask_layout asked_this_run false
  35.  
  36. CONFIGDIR=/etc/console-setup
  37. CONFIGFILE=/etc/default/console-setup
  38.  
  39. if [ "$1" = "configure" ]; then
  40.     
  41.     db_get console-setup/codesetcode
  42.     codeset="$RET"
  43.     db_get console-setup/fontface
  44.     fontface="$RET"
  45.     db_get console-setup/fontsize
  46.     fontsize="$RET"
  47.  
  48.     fontname=$codeset-$fontface$fontsize.psf.gz
  49.     
  50.     if which ckbcomp-mini >/dev/null; then
  51.     charmap=UTF-8
  52.     else
  53.     db_get console-setup/charmap
  54.     charmap="${RET:-UTF-8}"
  55.     fi
  56.  
  57.     db_get console-setup/ttys
  58.     ttys="$RET"
  59.  
  60.  
  61.     db_get console-setup/modelcode
  62.     model="$RET"
  63.  
  64.     db_get console-setup/layoutcode
  65.     layout="$RET"
  66.  
  67.     db_get console-setup/variantcode
  68.     variant="$RET"
  69.  
  70.     db_get console-setup/optionscode
  71.     options="$RET"
  72.  
  73.     if [ "$charmap" != UTF-8 ]; then
  74.     acm=$CONFIGDIR/$charmap.acm.gz
  75.     acm_option="-charmap $charmap"
  76.     else
  77.     acm=''
  78.     acm_option=''
  79.     fi
  80.  
  81.     if [ ! -e $CONFIGFILE ]; then
  82.     cat /usr/share/doc/console-setup/examples/console-setup \
  83.         /usr/share/doc/console-setup-mini/examples/console-setup \
  84.         /usr/share/console-setup-mini/console-setup.proto \
  85.         2>/dev/null >$CONFIGFILE || true
  86.     cat >>$CONFIGFILE <<EOF
  87.  
  88. # Do not update the following md5 sum if you change
  89. # $CONFIGDIR/boottime.kmap.gz and Debconf will not overwrite
  90. # your custom keymap.  Do not update it even if you want to make
  91. # Debconf overwrite it.  Instead simply specify the empty string as
  92. # a md5 sum.
  93.  
  94. BOOTTIME_KMAP_MD5=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  95. EOF
  96.     fi
  97.  
  98.     . $CONFIGFILE || true
  99.  
  100.     if [ "$model" = SKIP ]; then
  101.     BOOTTIME_KMAP_MD5=
  102.     elif \
  103.     [ -z "$BOOTTIME_KMAP_MD5" ] \
  104.     || [ ! -f "$CONFIGDIR/boottime.kmap.gz" ] \
  105.     || echo "$BOOTTIME_KMAP_MD5  $CONFIGDIR/boottime.kmap.gz" \
  106.         | $md5sum -c 2>/dev/null >/dev/null
  107.     then
  108.     if which gzip >/dev/null; then
  109.         ckbcomp $acm_option -model "$model" \
  110.         "$layout" "$variant" "$options" \
  111.         | gzip -9 >$CONFIGDIR/boottime.kmap.gz
  112.     fi
  113.     BOOTTIME_KMAP_MD5=`$md5sum $CONFIGDIR/boottime.kmap.gz | sed 's/ .*//'`
  114.     fi
  115.  
  116.     # Ensure we do not mess up the config file's ownership and permissions.
  117.     cp -a -f $CONFIGFILE $CONFIGFILE.tmp
  118.  
  119.     # If the admin deleted or commented some variables but then set
  120.     # them via debconf, (re-)add them to the conffile.
  121.     for var in \
  122.     ACTIVE_CONSOLES CHARMAP CODESET FONTFACE FONTSIZE \
  123.     XKBMODEL XKBLAYOUT XKBVARIANT XKBOPTIONS BOOTTIME_KMAP_MD5
  124.     do
  125.         if ! grep "^ *${var}=" $CONFIGFILE >/dev/null; then
  126.         echo "${var}=" >>$CONFIGFILE
  127.     fi
  128.     done    
  129.     
  130.     sed \
  131.     -e "s|^ *ACTIVE_CONSOLES=.*|ACTIVE_CONSOLES=\"$ttys\"|" \
  132.     -e "s|^ *CHARMAP=.*|CHARMAP=\"$charmap\"|" \
  133.     -e "s|^ *CODESET=.*|CODESET=\"$codeset\"|" \
  134.     -e "s|^ *FONTFACE=.*|FONTFACE=\"$fontface\"|" \
  135.     -e "s|^ *FONTSIZE=.*|FONTSIZE=\"$fontsize\"|" \
  136.     -e "s|^ *XKBMODEL=.*|XKBMODEL=\"$model\"|" \
  137.     -e "s|^ *XKBLAYOUT=.*|XKBLAYOUT=\"$layout\"|" \
  138.     -e "s|^ *XKBVARIANT=.*|XKBVARIANT=\"$variant\"|" \
  139.     -e "s|^ *XKBOPTIONS=.*|XKBOPTIONS=\"$options\"|" \
  140.     -e "s|^ *BOOTTIME_KMAP_MD5=.*|BOOTTIME_KMAP_MD5=\"$BOOTTIME_KMAP_MD5\"|" \
  141.     <$CONFIGFILE >$CONFIGFILE.tmp
  142.     
  143.     mv -f $CONFIGFILE.tmp $CONFIGFILE
  144. fi
  145.  
  146. # In d-i debhelper doesn't use /etc/init.d scripts :-)
  147. if [ -f /var/lib/dpkg/info/console-setup.config ]; then
  148.     if [ -d /lib/debian-installer ]; then
  149.     setupcon --force --save
  150.     else
  151.     # setting the font corrupts X
  152.     setupcon --save-only
  153.     setupcon --force -k
  154.     cat >&2 <<EOF
  155. Your console font configuration will be updated the next time your system
  156. boots. If you want to update it now, run 'setupcon' from a virtual console.
  157. EOF
  158.     fi
  159. fi
  160.  
  161. #DEBHELPER#
  162.  
  163. if type update-initramfs >/dev/null 2>&1; then
  164.     : update-initramfs -u
  165. fi
  166.  
  167. exit 0
  168.